﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace DynDns
{
    public partial class GUI : System.Web.UI.Page
    {
        string user;
        string rolle;

        protected void Page_Load(object sender, EventArgs e)
        {
            // check if user logged-in

            // load Server XML - Control Grid     
            Panel1.Controls.Add(LoadControl("Control_Server.ascx"));

            // read Cookie
            HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

            user = ticket.Name;
            rolle = ticket.CookiePath;
            bool expired = ticket.Expired;

            LabelUser.Text = user + "(" + rolle + ")";
        }

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            // logout
            FormsAuthentication.SignOut();
            FormsAuthentication.RedirectToLoginPage();
        }
    }
}